
% Stochastic discrete event system
clear all;

%%
%MC = EMarkovChain;

MC.S=[1,2,3,4];
MC.Sl={'s1', 's2', 's3', 's4'};

MC.E=[1,2,3];
MC.El={'t1','t2','t3'};

MC.ES=[1 1 1; 1 0 0; 0 1 1; 1 1 0];

MC.p(:,:,1)=[0 0 0 1; 1 0 0 0; 0 0 0 0; 0 1 0 0];

MC.p(:,:,2)=[0 1 0 0; 0 0 0 0; 0 1 0 0; 0 0 1 0];

MC.p(:,:,3)=[0 0 1 0; 0 0 0 0; 0 1 0 0; 0 0 0 0];

MC.G={'wbl', {5,1}; 'wbl', {1,1}; 'wbl', {2,10}};

% inverse matrix
MC.p(:,:,1) = MC.p(:,:,1)';
MC.p(:,:,2) = MC.p(:,:,2)';
MC.p(:,:,3) = MC.p(:,:,3)';

%%

itf_showMarkov(MC.S, MC.E, MC.ES, MC.p, MC.G);

%%
n_samples = 10000;
path = cell(n_samples,1);
lcc = cell(n_samples,1);
% Creation of sample executions
for i=1:n_samples
    seed = rand(1);
    [cc pp] = sim_interface(MC.S,MC.E,MC.ES,MC.p,MC.G, 10, seed);
    path{i} = [[0; double(pp(:,2))] [0; cc(:,end)]];
    lcc{i} = cc;
end
% End


% Learn this model
% ----------------
itf_ptasa(path,'method',1,'gui',1);

